package com.miyake.loveviewweb.shared.model;

import java.io.Serializable;

import com.google.appengine.api.datastore.Key;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

@Model(schemaVersion = 1)
public class DataColumnModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;

    @Attribute(version = true)
    private Long version;

    /**
     * Returns the key.
     *
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
    }

    /**
     * Returns the version.
     *
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((key == null) ? 0 : key.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        DataColumnModel other = (DataColumnModel) obj;
        if (key == null) {
            if (other.key != null) {
                return false;
            }
        } else if (!key.equals(other.key)) {
            return false;
        }
        return true;
    }
    
    /**
     * @return the header
     */
    public String getHeader() {
        return header;
    }

    /**
     * @param header the header to set
     */
    public void setHeader(String header) {
        this.header = header;
    }

    /**
     * @return the type
     */
    public ColumnDataType getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(ColumnDataType type) {
        this.type = type;
    }

    private String header;
//    private Key dataKey;
    private Key bodyKey;
    
    private ColumnDataType type;
    
    public enum ColumnDataType {
        Number, String
    }
    

    
    public DataColumnModel(String header, ColumnDataType type, Key bodyKey) {
        this.header = header;
        this.type = type;
        this.bodyKey = bodyKey;
    }
    
    public DataColumnModel(){}
/*
    *//**
     * @return the dataKey
     *//*
    public Key getDataKey() {
        return dataKey;
    }

    *//**
     * @param dataKey the dataKey to set
     *//*
    public void setDataKey(Key dataKey) {
        this.dataKey = dataKey;
    }*/

    /**
     * @return the bodyKey
     */
    public Key getBodyKey() {
        return bodyKey;
    }

    /**
     * @param bodyKey the bodyKey to set
     */
    public void setBodyKey(Key bodyKey) {
        this.bodyKey = bodyKey;
    }
   
    /**
     * @return the value
     */
    public String[] getValue() {
        return value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(String[] value) {
        this.value = value;
    }

    @Attribute(persistent=false)
    private String[] value;
}
